﻿
Public Module period

    Private t As UInt32

    Private Sub [set]()
        timeBeginPeriod(t)
    End Sub

    Private Sub reset()
        timeEndPeriod(t)
    End Sub

    Private Sub unhandledException(ByVal ex As Exception)
        reset()
    End Sub

    Public Sub main(ByVal args() As String)
        registerUnhandledException(AddressOf unhandledException)
        registerConsoleExtHandle()

        If args.Length = 0 OrElse Not convertor.touint32(args(0), t) Then
            t = 5
        End If
        [set]()
        While Not consoleExtSignal()
            sleep(1000)
        End While
        reset()
    End Sub
End Module
